#!/bin/tcsh -ef
#############################################################################
#                                                                           #
# Title: AUX-Clean up SPR directories                     					#
#                                                                           #
# (C) 2dx.org, GNU Plublic License.                                         #
#                                                                           #
# Created..........: 29/07/2016                                             #
# Last Modification: 29/07/2016                                             #
# Author...........: 2dx.org                                                #
#                                                                           #
#############################################################################
#
# SORTORDER: 130
#
#
# MANUAL: This script allows the user to clean up the Single Particle Refinement (SPR) folders.
#
# DISPLAY: SPR_DIR
# DISPLAY: SPR_PREREFINE_DIR
# DISPLAY: SPR_REFINE_DIR
# DISPLAY: SPR_CleanStacksDir
# DISPLAY: SPR_CleanPickDir
# DISPLAY: SPR_CleanFRLPreRefDir
# DISPLAY: SPR_CleanFRLScratchPreRefDir
# DISPLAY: SPR_CleanFRLRefDir
# DISPLAY: SPR_CleanFRLScratchRefDir
# DISPLAY: SPR_CleanSPR
# DISPLAY: SPR_CleanAll
#
#$end_local_vars
#
set bin_2dx = ""
set proc_2dx = ""

set scriptname = CleanUpSPR

#
set SPR_DIR = ""
set SPR_CleanStacksDir = ""
set SPR_CleanPickDir = ""
set SPR_CleanFRLPreRefDir = ""
set SPR_CleanFRLScratchPreRefDir = ""
set SPR_CleanFRLRefDir = ""
set SPR_CleanFRLScratchRefDir = ""
set SPR_CleanSPR = ""
set SPR_PREREFINE_DIR = ""
set SPR_REFINE_DIR = ""
set SPR_CleanAll = ""
#
set SPR_FREALIGN_DIR = ${SPR_DIR}/FREALIGN
#$end_vars

if ( -e LOGS/${scriptname}.results ) then
	mv LOGS/${scriptname}.results LOGS/${scriptname}.results.old
endif

if ( ${SPR_CleanSPR} == "y" ) then

	if ( ${SPR_CleanAll} == "y" ) then

		echo ":: Removing all contents of SPR directory..."
		rm -Rf ${SPR_DIR}

	endif

	if ( ${SPR_CleanStacksDir} == "y" ) then

		echo ":: Removing contents of stacks directory..."
		rm -Rf ${SPR_DIR}/stacks

	endif

	if ( ${SPR_CleanPickDir} == "y" ) then

		echo ":: Removing contents of picking directory..."
		rm -Rf ${SPR_DIR}/picking

	endif

	if ( ${SPR_CleanFRLPreRefDir} == "y" ) then

		echo ":: Removing contents of FREALIGN pre-refinement directory..."
		rm -Rf ${SPR_DIR}/FREALIGN/${SPR_PREREFINE_DIR}

	endif

	if ( ${SPR_CleanFRLScratchPreRefDir} == "y" ) then

		echo ":: Removing contents of FREALIGN pre-refinement scratch directory..."
		rm -Rf ${SPR_DIR}/FREALIGN/${SPR_PREREFINE_DIR}/scratch

	endif

	if ( ${SPR_CleanFRLRefDir} == "y" ) then

		echo ":: Removing contents of FREALIGN refinement directory..."
		rm -Rf ${SPR_DIR}/FREALIGN/${SPR_REFINE_DIR}

	endif

	if ( ${SPR_CleanFRLScratchRefDir} == "y" ) then

		echo ":: Removing contents of FREALIGN refinement scratch directory..."
		rm -Rf ${SPR_DIR}/FREALIGN/${SPR_REFINE_DIR}/scratch

	endif

	echo ":: Done!"

else if ( ${SPR_CleanSPR} == "n" ) then

	echo ":: Nothing done."
	endif

endif
